package com.project.controller;

import com.project.entity.Permission;
import com.project.entity.RestPOJO;
import com.project.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class PermissionController {

    @Autowired
    private PermissionService permissionService;

    @GetMapping("/menus/{id}")
    public RestPOJO getPersByUser(@PathVariable("id") Integer id){
        RestPOJO restPOJO = new RestPOJO();
        //找一级功能及对应的二级功能
        List<Permission> pers = permissionService.getPersByUser(id,0);
        if(pers.size()>0){
            restPOJO.setData(pers);
            restPOJO.setStatus(1000);
            restPOJO.setMessages("成功");
        }
        else{
            restPOJO.setStatus(1001);
            restPOJO.setMessages("失败");
        }
        return restPOJO;
    }
}
